package edu.sctu.nieyu.day20150607.thread;

/**
 * Created by user01 on 2015/6/7.
 */
public class ThreadUtil {

    private int time;

    public ThreadUtil(int time) {
        this.time = time;
    }
    public void startThread(){
        new Thread(){
          public void run(){
              super.run();
              for (int i = 0; i < time; i++) {
                  System.out.println(i);
                  try {
                      Thread.sleep(1000);
                  }catch (InterruptedException e){
                      e.printStackTrace();
                  }

              }
          }
        }.start();
    }

    public void threadRunable(){
        Thread thread = new Thread(new TestRunable());
        thread.start();
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadUtil tu = new ThreadUtil(10);
        tu.startThread();
        Thread.sleep(10000);
        tu.threadRunable();
    }
}
